import React, { Component } from 'react';
import { Card, Collapse, Form, Button } from 'antd';
import Link from 'umi/link';
import { formatMessage } from 'umi/locale';
import { connect } from 'dva';
import CbjZmcTool from './CbjZmcTool';
import LineCameraCalibraion from './LineCameraCalibraion';
import LineCameraJoint from './LineCameraJoint';
import CutterCameraCalibration from './CutterCameraCalibration';
import LineCameraCalibraionNinePoints from './LineCameraCalibraionNinePoints';

@connect(({ ds, produce }) => ({ ds, produce }))
@Form.create()
class HdTools extends Component {
  constructor(props) {
    super(props);
  }
  state = {};
  GuardBarAccessShield = e => {
    const { dispatch } = this.props;
    dispatch({
      type: 'produce/GuardBarAccessShield',
    });
  };
  bufferTableCounterShielding = e => {
    const { dispatch } = this.props;
    dispatch({
      type: 'produce/bufferTableCounterShielding',
    });
  };
  cacheCartShielding = e => {
    const { dispatch } = this.props;
    dispatch({
      type: 'produce/cacheCartShielding',
    });
  };
  offlineFeedingTableShielding = e => {
    const { dispatch } = this.props;
    dispatch({
      type: 'produce/offlineFeedingTableShielding',
    });
  };

  render() {
    const Panel = Collapse.Panel;
    const { shieldStart } = this.props.ds;
    return (
      <>
        <Collapse onChange={this.callback} style={{ marginLeft: 220 }}>
          <Panel header="离线上料屏蔽按钮" key="1">
            <Card >
              {shieldStart[0] ? (<Button onClick={this.GuardBarAccessShield} style={{ color: '#00FF00',marginLeft: 10 }}>
              防护栏门禁已屏蔽
            </Button>):(<Button onClick={this.GuardBarAccessShield} style={{ color: '#FF0000',marginLeft: 10 }}>
              防护栏门禁未屏蔽
            </Button>)}
              {shieldStart[1] ? (<Button onClick={this.bufferTableCounterShielding} style={{ color: '#00FF00',marginLeft: 20 }}>
              缓存台对射已屏蔽
            </Button>):(<Button onClick={this.bufferTableCounterShielding} style={{ color: '#FF0000',marginLeft: 20 }}>
              缓存台对射未屏蔽
            </Button>)}
              {shieldStart[3] ? (<Button onClick={this.cacheCartShielding} style={{ color: '#00FF00',marginLeft: 10 }}>
              缓存小车已屏蔽
            </Button>):(<Button onClick={this.cacheCartShielding} style={{ color: '#FF0000',marginLeft: 10 }}>
              缓存小车未屏蔽
            </Button>)}
              {shieldStart[4] ? (<Button onClick={this.offlineFeedingTableShielding} style={{ color: '#00FF00',marginLeft: 10 }}>
              离线上料台已屏蔽
            </Button>):(<Button onClick={this.offlineFeedingTableShielding} style={{ color: '#FF0000',marginLeft: 10 }}>
              离线上料台未屏蔽
            </Button>)}
            </Card>
          </Panel>
          <Panel header="裁切机控制器工具" key="2">
            <CbjZmcTool />
          </Panel>
          <Panel header="上料相机拼接工具" key="3">
            <LineCameraJoint />
          </Panel>
          <Panel header="上料相机标定工具" key="4">
            <LineCameraCalibraion />
          </Panel>
          <Panel header="上料相机九点标定工具" key="5">
            <LineCameraCalibraionNinePoints />
          </Panel>
          <Panel header="铡刀相机标定工具" key="6">
            <CutterCameraCalibration />
          </Panel>
        </Collapse>
      </>
    );
  }
}
export default HdTools;
